import math

def get_factors(n):
    """返回数字n的所有因子"""
    factors = set()
    sqrt_n = math.isqrt(n)
    for i in range(1, sqrt_n + 1):
        if n % i == 0:
            factors.add(i)
            factors.add(n // i)
    return sorted(factors)

def main():
    try:
        n = int(input("请输入一个正整数: "))
        if n <= 0:
            raise ValueError("输入必须是正整数。")
        factors = get_factors(n)
        print(' '.join(map(str, factors)))
    except ValueError as e:
        print(f"输入错误: {e}")

if __name__ == "__main__":
    main()